home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************\
- * *
- * DiceConfig *
- * *
- * (C) LF Soft 1992 *
- * *
- *****************************************************************************
- * *
- * Ce programme permet de configurer façilement DICE en sélèctionnant les *
- * options activées dans DCCOPTS. En plus des options standards, DiceConfig *
- * va chercher dans DLIB:DiceConfig.cfg les informations concernant les libs *
- * que l'on peut utiliser. Le format de ce fichier est le suivant : *
- * *
- * 1er ligne : Commande qui doivent toujours faire partie de DCCOPTS *
- * par exemple -1.3 -f -ms -// *
- * *
- * Suivent ensuite des groupes de 2 lignes dont la premiere indique le *
- * nom de la librairie, et la seconde les options a mettre dans DCCOPTS *
- * *
- *****************************************************************************
- * *
- * Date Version Par Remarques *
- * ------ --------- ----- ----------- *
- * 02-Sep-1992 1.0 L.Faillie Limite de 10 Librairies *
- * nom de 8 caracteres, & ligne d' *
- * options limitées a 80 caracteres *
- * *
- *****************************************************************************
- * *
- * Note: Dice est © M.Dillon, mais DiceConfig est © LF Soft 1992. *
- * Ce programme est un FreeWare ( mais des contributions ne sont pas *
- * refusées ;-) ). Il utilise beaucoup de propriétés propre a DICE ce *
- * qui indique qu'il ne peut etre recompilé avec d'autres compilateurs. *
- * De plus certaines options comme -profx ou -unix ne sont disponibles *
- * qu'avec la version enregistré du compilateur. *
- * Pour ceux qui regarde ce source : Non, auccune librairie Amiga n'est *
- * ouverte car DICE le fait tous seul !! *
- * *
- * Compillé & testé sur un Amiga 1000 sous WB & KS 1.3, 68010, 2Mo de RAMs *
- * & un disque dur de 52 Mo avec la version 2.06.40 R de Dice. *
- * Gadets créés par POWERSOURCE V3.0 & test avec CSH v5.19 *
- * *
- *****************************************************************************
- * *
- * Laurent FAILLIE *
- * " Les Vuardes " *
- * 74930 Pers-Jussy *
- * FRANCE *
- * *
- \*****************************************************************************/
-
- #include <exec/types.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <intuition/intuition.h>
- #include <graphics/gfxbase.h>
- // #include <LF.h>
-
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
-
- char exist(char *fn)
- {
- struct FileLock *fl,*Lock();
-
- if(!(fl=Lock(fn,ACCESS_READ)))
- return(0);
-
- UnLock(fl);
- return(1);
- }
-
- #include <stdio.h>
-
- char *LFgets(FILE *f,char *l,size_t max)
- /* Lit une chaine & efface un eventuel \n */
- {
- size_t i;
-
- fgets(l,max,f);
- if (l[(i=strlen(l)-1)]=='\n') l[i]=0;
- return(l);
- }
-
-
- // Messages d'erreurs
-
- const char *w_conf[]={"\x1b[33mCan't find config file\x1b[0m",
- "\x1b[33mFichier de config absant\x1b[0m"},
- *w_act[]={"Action line too long","ligne d'Action trops longue"},
- *err_var[]={"Can't update variable","La variable ne peut pas etre mise a jour"},
- *err_fntre[]={"Can't open window","Impossible d'ouvrir la fenetre"};
-
- // Pour utiliser façilement les gadgets.
-
- #define Val(x) ((((struct PropInfo*)((x).SpecialInfo))->VertPot)/0x3fff)
- #define SetVal(x,i) ((struct PropInfo*)((x).SpecialInfo))->VertPot = (i)*0x3fff
-
- #define Sel(x) (((x).Flags & SELECTED) ? 1:0)
- #define SetSel(x,i) (x).Flags &=~SELECTED;(x).Flags |= ((i)?SELECTED:0)
-
-
- // Fichiers utilisés
-
- #ifdef DEBUG
- #define CONFIGNAME "VD0:DiceConfig.cfg"
- #define DCCENV "VD0:DCCOPTS"
- #else
- #define CONFIGNAME "DLIB:DiceConfig.cfg"
- #define DCCENV "ENV:DCCOPTS"
- #endif
-
-
- // Définitions des variables de Configs, ceci permet de retrouver les memes
- // gadgets selectionnées lorsque le programme est relancé. Mieux que __shared
- // qui ne passe pas avec ARP.
-
- // define pour les gadgets.
- #define PURE 1
- #define UNIX 2
- #define DYNASTACK 4
- #define DBG 8
- #define LIBBASE 4
-
- char *ConfigFile = "T:DiceConfig.config";
- long ConfigVersion = 1;
-
- __config UBYTE prof=0; // Valeur du prof
- __config UWORD gad=0; // Gadgets selectionnés
-
-
- // Definitions des gadgets ( Mis en tableau pour façilité la programmation )
-
- /*---------------------------------------------------*
- Gadgets created with PowerSource V3.0
- which is (c) Copyright 1990-91 by Jaba Development
- written by Jan van den Baard
- *---------------------------------------------------*/
-
- SHORT SharedBordersPairs0[] = {
- 0,0,0,14,1,13,1,0,80,0 };
- SHORT SharedBordersPairs1[] = {
- 1,14,80,14,80,1,81,0,81,14 };
- SHORT BorderprofP1[]={
- 0,0,0,102,1,101,1,0,82,0},
- BorderprofP2[]={
- 1,102,82,102,82,1,83,0,83,102};
-
- struct Border SharedBorders[] = {
- 0,0,1,0,JAM1,5,(SHORT *)&SharedBordersPairs0[0],&SharedBorders[1],
- 0,0,2,0,JAM1,5,(SHORT *)&SharedBordersPairs1[0],NULL },
- Borderprof[] = {
- 0,0,1,0,JAM1,5,(SHORT *)&BorderprofP1[0],&Borderprof[1],
- 0,0,2,0,JAM1,5,(SHORT *)&BorderprofP2[0],NULL };
-
-
- struct TextAttr TOPAZ80 = {
- (STRPTR)"topaz.font",
- TOPAZ_EIGHTY,0,0
- };
-
- struct IntuiText g_cancel_text = {
- 1,0,JAM2,20,4,&TOPAZ80,(UBYTE *)"CANCEL",NULL };
-
- #define g_cancel_ID 16
-
- struct Gadget g_cancel = {
- NULL,299,128,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_cancel_text,NULL,NULL,g_cancel_ID,NULL };
-
- struct IntuiText g_ok_text = {
- 1,0,JAM2,30,4,&TOPAZ80,(UBYTE *)"OK",NULL };
-
- #define g_ok_ID 15
-
- struct Gadget g_ok = {
- &g_cancel,77,128,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_ok_text,NULL,NULL,g_ok_ID,NULL };
-
- #define g_lib9_ID 14
- #define g_lib8_ID 13
- #define g_lib7_ID 12
- #define g_lib6_ID 11
- #define g_lib5_ID 10
- #define g_lib4_ID 9
- #define g_lib3_ID 8
- #define g_lib2_ID 7
- #define g_lib1_ID 6
- #define g_lib0_ID 5
-
- // Tableau comportant les librairies
-
- char lib[10][8], // Text affiché
- liba[10][80]; // action sur DCCOPTS
-
- struct IntuiText
- g_lib_titre = { 1,0,JAM1,52,-11,&TOPAZ80,(UBYTE *)"Libraries",NULL},
- g_lib_txt[]={
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[0],&g_lib_titre,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[1],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[2],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[3],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[4],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[5],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[6],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[7],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[8],NULL,
- 3,0,JAM1,14,4,&TOPAZ80,(UBYTE *)lib[9],NULL
- };
-
- struct Gadget g_lib[] ={
- {
- &g_lib[1],237,25,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[0],NULL,NULL,g_lib0_ID,NULL
- },{
- &g_lib[2],323,25,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[1],NULL,NULL,g_lib1_ID,NULL
- },{
- &g_lib[3],237,42,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[2],NULL,NULL,g_lib2_ID,NULL
- },{
- &g_lib[4],323,42,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[3],NULL,NULL,g_lib3_ID,NULL
- },{
- &g_lib[5],237,59,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[4],NULL,NULL,g_lib4_ID,NULL
- },{
- &g_lib[6],323,59,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[5],NULL,NULL,g_lib5_ID,NULL
- },{
- &g_lib[7],237,76,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[6],NULL,NULL,g_lib6_ID,NULL
- },{
- &g_lib[8],323,76,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[7],NULL,NULL,g_lib7_ID,NULL
- },{
- &g_lib[9],237,93,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[8],NULL,NULL,g_lib8_ID,NULL
- },{
- &g_ok,323,93,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_lib_txt[9],NULL,NULL,g_lib9_ID,NULL
- }
- };
-
- struct IntuiText g_debug_text = {
- 3,0,JAM1,21,3,&TOPAZ80,(UBYTE *)"Debug",NULL };
-
- #define g_debug_ID 4
-
- struct Gadget g_debug = {
- &g_lib[0],114,95,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_debug_text,NULL,NULL,g_debug_ID,NULL };
-
- struct IntuiText g_dynastack_text = {
- 3,0,JAM1,5,4,&TOPAZ80,(UBYTE *)"DynaStack",NULL };
-
- #define g_dynastack_ID 3
-
- struct Gadget g_dynastack = {
- &g_debug,114,71,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_dynastack_text,NULL,NULL,g_dynastack_ID,NULL };
-
- struct IntuiText g_unix_text = {
- 3,0,JAM1,24,4,&TOPAZ80,(UBYTE *)"Unix",NULL };
-
- #define g_unix_ID 2
-
- struct Gadget g_unix = {
- &g_dynastack,113,47,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_unix_text,NULL,NULL,g_unix_ID,NULL };
-
- struct IntuiText g_pure_text = {
- 3,0,JAM1,26,3,&TOPAZ80,(UBYTE *)"Pure",NULL };
-
- #define g_pure_ID 1
-
- struct Gadget g_pure = {
- &g_unix,113,24,82,15,
- GADGHCOMP,
- TOGGLESELECT+RELVERIFY,
- BOOLGADGET,
- (APTR)&SharedBorders[0],NULL,
- &g_pure_text,NULL,NULL,g_pure_ID,NULL };
-
- struct PropInfo g_prof_info = {
- AUTOKNOB+FREEVERT,0x0000,0x0000,0xFFFF,0x3333,0,0,0,0,0,0 };
-
- struct Image g_prof_image;
-
- struct IntuiText g_prof_text[] = {
- 3,0,JAM1,-39,26,&TOPAZ80,(UBYTE *)"Prof",&g_prof_text[1],
- 3,0,JAM1,-38,5,&TOPAZ80,(UBYTE *)"None",&g_prof_text[2],
- 3,0,JAM1,-43,46,&TOPAZ80,(UBYTE *)"Prof1",&g_prof_text[3],
- 3,0,JAM1,-43,64,&TOPAZ80,(UBYTE *)"Prof2",&g_prof_text[4],
- 3,0,JAM1,-43,83,&TOPAZ80,(UBYTE *)"Prof3",NULL };
-
- #define g_prof_ID 0
-
- struct Gadget g_prof = {
- &g_pure,59,24,26,97,
- GADGHCOMP,
- RELVERIFY,
- PROPGADGET,
- (APTR)&g_prof_image,NULL,
- &g_prof_text[0],NULL,(APTR)&g_prof_info,g_prof_ID,NULL };
-
- struct NewWindow nwin = {
- 98,36,437,151,0,1,
- GADGETDOWN+GADGETUP+CLOSEWINDOW,
- WINDOWDRAG+WINDOWDEPTH+NOCAREREFRESH+SMART_REFRESH+ACTIVATE,
- &g_prof,NULL,
- (UBYTE *)"Dice config V1.0 © LF Soft 1992",NULL,NULL,
- 150,50,640,262,WBENCHSCREEN };
-
-
- #define NEWWINDOW &nwin
- #define WDBACKFILL 0
- #define FIRSTGADGET &g_prof
-
-
- struct IntuiMessage *Message = NULL;
- struct Window *window=NULL;
- FILE *f=NULL;
- UBYTE lang=0;
-
- void by(){
- if(f) fclose(f);f=NULL;
- if (window)
- CloseWindow(window);
- }
-
- void Fatal(char *msg)
- {
- char buff[100];
-
- buff[0]=0;buff[1]=50;buff[2]=17;
- strcpy(&buff[3],msg);
- buff[4+strlen(msg)]=0;
- DisplayAlert(RECOVERY_ALERT,buff,30);
- exit(15);
- }
-
- void main(){
- short NuGadg;
- long class;
- char l[256],defa[256],*var;
-
- if(var=getenv("Lang")){
- if(!stricmp(var,"Français"))
- lang=1;
- }
-
- if((window = (struct Window *)
- OpenWindow(NEWWINDOW))==0)
- Fatal(err_fntre[lang]);
-
- atexit(by);
-
- for(NuGadg=0;NuGadg<10;NuGadg++) // Si init direct, les gadgets
- g_lib[NuGadg].Flags |=GADGDISABLED; // sont mal dessinés
-
- if(f=fopen(CONFIGNAME,"r")){
- LFgets(f,defa,255); // Lecture des commandes par defaut
- if(feof(f))
- *defa=0;
- else {
- for(NuGadg=0;NuGadg<10;NuGadg++){
- LFgets(f,l,255); // Lecture du texte
- strncpy(lib[NuGadg],l,7);
- lib[NuGadg][7]=0;
- LFgets(f,l,255); // Lecture de l'actions
- if(strlen(l)>79)
- printf("\x1b[33m%s (lib %d)\x1b[0m\n",w_act[lang],NuGadg+1);
- strncpy(liba[NuGadg],l,79);
- liba[NuGadg][79]=0;
- if(feof(f)){
- *lib[NuGadg]=0;
- break;
- } else
- g_lib[NuGadg].Flags &=~GADGDISABLED;
- }
- }
- fclose(f);f=NULL;
- } else
- puts(w_conf[lang]);
-
- DrawBorder(window->RPort,&Borderprof[0],9,21);
-
- // Selectionne les gadgets suivant la config
- SetVal(g_prof,prof);
- SetSel(g_pure,gad & PURE);
- SetSel(g_unix,gad & UNIX);
- SetSel(g_dynastack,gad & DYNASTACK);
- SetSel(g_debug,gad & DBG);
- for(NuGadg=0;NuGadg<10;NuGadg++){
- if(g_lib[NuGadg].Flags & GADGDISABLED)
- break;
- SetSel(g_lib[NuGadg],gad & (1<<(LIBBASE+NuGadg)));
- }
- if(!exist(DCCENV))
- g_cancel.Flags |= GADGDISABLED;
-
- RefreshGadgets(&g_prof,window,NULL);
-
- FOREVER{
- Wait(1L << window->UserPort->mp_SigBit);
- while(Message = (struct IntuiMessage *)GetMsg(window->UserPort)) {
- NuGadg=((struct Gadget *)Message->IAddress)->GadgetID;
- class=Message->Class;
- ReplyMsg(Message);
- if(class==GADGETUP)
- switch (NuGadg){
- case g_prof_ID:
- SetVal(g_prof,Val(g_prof));
- RefreshGList(&g_prof,window,NULL,1);
- #ifdef DEBUG
- printf("%d\n",Val(g_prof));
- #endif
- break;
- case g_cancel_ID:
- exit(0);
- case g_ok_ID:
- // Sauvegarde de la config & mise a jour de la variable
- if(!(f=fopen(DCCENV,"w")))
- Fatal(err_var[lang]);
- fprintf(f,"%s ",defa);
- switch(prof=Val(g_prof)){
- case 1:
- fputs("-prof ",f);break;
- case 2:
- fputs("-prof1 ",f);break;
- case 3:
- fputs("-prof2 ",f);break;
- case 4:
- fputs("-prof3 ",f);break;
- }
- if(Sel(g_pure)){
- gad = PURE;
- fputs("-r ",f);
- } else
- gad = 0;
- if(Sel(g_unix)){
- gad |= UNIX;
- fputs("-unix ",f);
- }
- if(Sel(g_dynastack)){
- gad |= DYNASTACK;
- fputs("-gs ",f);
- }
- if(Sel(g_debug)){
- gad |= DBG;
- fputs("-DDEBUG -s ",f);
- }
- for(NuGadg=0;NuGadg<10;NuGadg++)
- if(Sel(g_lib[NuGadg])){
- gad |= 1<<(LIBBASE+NuGadg);
- fprintf(f,"%s ",liba[NuGadg]);
- }
- #ifdef DEBUG
- printf("Config :%d, %x\n",prof,gad);
- #endif
- exit(0);
- }
- }
- }
- }
-